//
//  HCGrowthAlbumHeaderView.m
//  HappyChildren
//
//  Created by WillyZhao on 2017/1/19.
//  Copyright © 2017年 WillyZhao. All rights reserved.
//

#import "HCGrowthAlbumHeaderView.h"

@implementation HCGrowthAlbumHeaderView

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self initializeSubView:frame];
    }
    return self;
}

-(void)initializeSubView:(CGRect)frame {
    
    UIImage *image = [UIImage imageNamed:@"happy_GrowthAlbum_headBG"];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, YBKAdaptiveH(256))];
    imageView.image = image;
    imageView.userInteractionEnabled = YES;
    [self addSubview:imageView];
    
    UIImage *imagess = [UIImage imageNamed:@"happy_GrowthAlbum_head"];
    
    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(frame.size.width - YBKAdaptiveW(10) - YBKAdaptiveW(75), imageView.frame.size.height - YBKAdaptiveW(75)/2.0, YBKAdaptiveW(75), YBKAdaptiveW(75))];
    bottomView.backgroundColor = [UIColor whiteColor];
    [self addSubview:bottomView];

    self.imageViewss = [[UIImageView alloc] initWithFrame:CGRectMake(1, 1, bottomView.frame.size.width-2, bottomView.frame.size.height-2)];
    self.imageViewss.image = imagess;
    [bottomView addSubview:self.imageViewss];
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, imageView.frame.size.height - 20-YBKAdaptiveH(7), self.imageViewss.frame.origin.x - 4, 20)];
    self.nameLabel.textColor = [UIColor whiteColor];
    self.nameLabel.text = @"";
    self.nameLabel.textAlignment = NSTextAlignmentRight;
    [imageView addSubview:self.nameLabel];
    self.imageViewss.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headClick:)];
    [self.imageViewss addGestureRecognizer:tap];
}

- (void)headClick:(UIGestureRecognizer *)gesture {

    if (self.didClickHeadBlock) {
        self.didClickHeadBlock();
    }
}

@end
